import 'package:flutter/material.dart';
import 'package:laoba_menu/views/search/Search.dart';

// 头部搜索框
class Header extends StatefulWidget {
  @override
  HeaderState createState() => new HeaderState();
}

class HeaderState extends State<Header> {
  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      child: Container(
        decoration: BoxDecoration(boxShadow: [
          BoxShadow(
              color: Colors.white,
              offset: Offset(0.0, 0), //阴影xy轴偏移量
              blurRadius: 1.0, //阴影模糊程度
              spreadRadius: 1.0 //阴影扩散程度
              )
        ]),
        child: Padding(
            padding: const EdgeInsets.fromLTRB(20, 50, 20, 10),
            // 头部搜索框
            child: Flex(
              direction: Axis.horizontal,
              children: [
                Expanded(
                  flex: 1,
                  child: Container(
                    decoration: BoxDecoration(
                        borderRadius: BorderRadius.circular(30),
                        color: Color.fromRGBO(239, 240, 241, 1)),
                    child: Padding(
                      padding: const EdgeInsets.fromLTRB(20, 10, 20, 10),
                      child: Row(
                        children: [
                          Icon(Icons.search,
                              color: Color.fromRGBO(163, 164, 165, 1)),
                          Text(
                            "搜索菜谱或食材",
                            style: TextStyle(
                                color: Color.fromRGBO(163, 164, 165, 1),
                                fontSize: 15),
                          )
                        ],
                      ),
                    ),
                  ),
                )
              ],
            )),
      ),
      onTap: () => jumpSearchPage(),
    );
  }

  void jumpSearchPage() {
    Navigator.push(context, MaterialPageRoute(builder: (context) {
      return Search(text: '传来的标题');
    }));
  }
}
